﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace bChatServerDAL
{
    public static class ServerLog
    {
        public static void LogEvent(string Type, string Module, string Operation, string Comment, Exception Ex = null, bool ThrowLoggerException = false)
        {
            try
            {
                ServerLogHookEvent(null, new ServerLogHookEventArgs
                {
                    Comment=Comment,
                    Ex=Ex,
                    Module=Module,
                    Operation =Operation,
                    Type=Type
                });


                //implement on demand

            }
            catch (Exception ex)
            {
                
            }
        }

        public static event ServerLogHookEventHandler ServerLogHookEvent;

        public delegate void ServerLogHookEventHandler(object sender, ServerLogHookEventArgs e);

    }

    



    public class ServerLogHookEventArgs : EventArgs
    {
        public string Type { get; set; }

        public string Module { get; set; }

        public string Operation { get; set; }

        public string Comment { get; set; }

        public Exception Ex { get; set; }

        public override string ToString()
        {
            return Type + ":" + Module + ":" + Operation + ":" + Comment + ":" + (Ex!=null ? Ex.Message :"");
        }

    }
}
